#include "mainwindow.h"
#include <KLocalizedString>
#include <QDebug>
#include <QLabel>
#include <QPushButton>
#include <QTimer>
#include <QVBoxLayout>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
}

MainWindow::~MainWindow()
{
}

void MainWindow::init()
{
    setMinimumWidth(240);

    setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); //无边框、禁止拖动、禁止改变大小、不受窗管管理
    // setAttribute(Qt::WA_TranslucentBackground);                    //透明背景
    setAttribute(Qt::WA_AlwaysShowToolTips);
    setAttribute(Qt::WA_ShowWithoutActivating);
    setAttribute(Qt::WA_X11NetWmWindowTypeNotification);

    QLabel *infoLabel = new QLabel();
    infoLabel->setText(QStringLiteral("Compositor provides a serverSideDecoMgr"));
    infoLabel->adjustSize();

    QPushButton *hasKeyStateLabel = new QPushButton(this);
    QString dd = i18n("Maximize");
    hasKeyStateLabel->setText(i18n("Maximize"));
    QObject::connect(hasKeyStateLabel, &QPushButton::clicked, this, &MainWindow::slotButton);
}

void MainWindow::slotButton()
{
    hide();
    QIcon::setThemeName("ukui-icon-theme-default");
    QTimer::singleShot(2000, this, [this]() {
        qWarning() << "[=== checkmode ===]"
                   << "show";
        show();
        QIcon::setThemeName("ukui-icon-theme-classical");
    });
}
